﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Media.Animation;
using System.Windows;

namespace Hugo
{
    class AnimationFactory
    {
        public static DoubleAnimation getContinuousFadeAnimation()
        {
            DoubleAnimation myDoubleAnimation = new DoubleAnimation();
            myDoubleAnimation.From = 0;
            myDoubleAnimation.To = 1;
            myDoubleAnimation.Duration = new System.Windows.Duration(TimeSpan.FromSeconds(3));
            myDoubleAnimation.AutoReverse = true;
            myDoubleAnimation.RepeatBehavior = RepeatBehavior.Forever;
            return myDoubleAnimation;
            //Storyboard.SetTargetName(myDoubleAnimation, myRectangle.Name);
            //Storyboard.SetTargetProperty(myDoubleAnimation,
            //    new PropertyPath(Rectangle.WidthProperty));
        }

        public static DoubleAnimation getFadeInAnimation()
        {
            DoubleAnimation myDoubleAnimation = new DoubleAnimation();
            myDoubleAnimation.From = 0;
            myDoubleAnimation.To = 1;
            myDoubleAnimation.Duration = new System.Windows.Duration(TimeSpan.FromSeconds(1));
            return myDoubleAnimation;
        }

        public static DoubleAnimation getFadeOutAnimation()
        {
            DoubleAnimation myDoubleAnimation = new DoubleAnimation();
            myDoubleAnimation.From = 1;
            myDoubleAnimation.To = 0;
            myDoubleAnimation.Duration = new System.Windows.Duration(TimeSpan.FromMilliseconds(500));
            return myDoubleAnimation;
        }

        public static DoubleAnimation getShiftAnimation(double from, double amount)
        {
            return getShiftAnimation(from, amount, 400);
        }

        public static DoubleAnimation getShiftAnimation(double from, double amount, int duration)
        {
            DoubleAnimation myDoubleAnimation = new DoubleAnimation();
            myDoubleAnimation.From = from;
            myDoubleAnimation.To = from + amount;
            myDoubleAnimation.Duration = new System.Windows.Duration(TimeSpan.FromMilliseconds(duration));
            return myDoubleAnimation;
        }

        public static DoubleAnimation getScaleAnimation(double from, double to)
        {
            DoubleAnimation myDoubleAnimation = new DoubleAnimation();
            myDoubleAnimation.From = from;
            myDoubleAnimation.To = to;
            myDoubleAnimation.Duration = new System.Windows.Duration(TimeSpan.FromMilliseconds(400));
            return myDoubleAnimation;
        }

        public static void runStoryBoard(MainWindow w, DoubleAnimation an, String name, System.Windows.PropertyPath prop)
        {
            Storyboard myStoryboard3 = new Storyboard();
            myStoryboard3.Children.Add(an);
            Storyboard.SetTargetName(an, name);
            Storyboard.SetTargetProperty(an, prop);

            myStoryboard3.Begin(w);
        }

        internal static DoubleAnimation getFastContinuousFadeAnimation(double from, double to)
        {
            DoubleAnimation myDoubleAnimation = new DoubleAnimation();
            myDoubleAnimation.From = from;
            myDoubleAnimation.To = to;
            myDoubleAnimation.Duration = new System.Windows.Duration(TimeSpan.FromMilliseconds(500));
            myDoubleAnimation.AutoReverse = true;
            myDoubleAnimation.RepeatBehavior = RepeatBehavior.Forever;
            return myDoubleAnimation;
        }
    }
}
